#!/bin/sh

set -eu


if [ -n "${CARCH:-}" ] || \
   CARCH="$(${APK:-apk} --print-arch 2> "/dev/null")"; then
	for _klibcso in "/lib/klibc-"*".so"; do
		if [ -L "${_klibcso}" ] && \
		   ! readlink -f "${_klibcso}"; then
			unlink "${_klibcso}"
		fi
	done

	ln -f -s "/usr/lib/klibc-${CARCH}/lib/klibc-"*".so" "/lib/"
fi

exit 0
